<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<script type="text/javascript">
    var rowId = 0;
    
    $('.ui-reset , #refresh_businessGrid').click(function(){
        $("#businessGrid").jqGrid('setGridParam',{search:false});
        var postData = $("#businessGrid").jqGrid('getGridParam','postData');
        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
        $.extend(postData,{filters:""});
        $("#businessGrid").trigger("reloadGrid");
    });

    $.subscribe('searchBusinessGrid', function(event,data) {
        $("#businessGrid").jqGrid('searchGrid', {drag:true,closeAfterSearch:true,closeOnEscape:true,sopt:['eq'],caption:"Search Business"} );
    });
    
    $.subscribe('businessGridComplete',function(event,data){
        $( "#businessGrid_search" ).button( "option", "disabled", false );
        $( "#businessGrid_showhide" ).button( "option", "disabled", false );
    });
    
    $.subscribe('showhideBusinessGrid', function(event,data) {
        $("#businessGrid").jqGrid('setColumns',{});
    });
</script>
<div class="gridOptsContainer">
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="businessGrid_search" onClickTopics="searchBusinessGrid" value="Search Business"/>
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="businessGrid_showhide" onClickTopics="showhideBusinessGrid" value="Show/Hide Columns"/>
</div>
<s:url id="remoteurl" action="grid-business"/>
<s:url id="editurl" action="edit-business"/>
<sjg:grid
    id="businessGrid"
    caption="Cashmate Borrower Businesses"
    dataType="json"
    href="%{remoteurl}"
    cellEdit="true"
    cellurl="%{editurl}"
    gridModel="gridModel"
    pager="true"
    pagerButtons="true"
    pagerInput="true"
    rowList="15,30,50"
    rowNum="15"
    loadingText="Requesting Data..."
    width="970"
    shrinkToFit="true"
    hoverrows="true"
    rownumbers="true"
    autoencode="true"
    viewrecords="true"
    navigator="true"
    navigatorAdd="false"
    navigatorDelete="false"
    navigatorEdit="false"
    navigatorSearch="true"
    navigatorView="true"
    onGridCompleteTopics="businessGridComplete"
    >

    <sjg:gridColumn name="businessid"
                    key="true"
                    index="businessid"
                    title="businessid. (Not Editable)"
                    sortable="false"
                    hidden="true"
                    align="center"
                    />

    <sjg:gridColumn name="businessname"
                    index="businessname"
                    title="Business Name"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="businesstype"
                    index="businesstype"
                    title="Type"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="dailyaveragesales"
                    index="dailyaveragesales"
                    title="Daily Average Sales"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    hidden="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="streetaddress"
                    index="streetaddress"
                    title="Street Address"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="barangay"
                    index="barangay"
                    title="Barangay"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />

    <sjg:gridColumn name="cityormunicipality"
                    index="cityormunicipality"
                    title="City"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="province"
                    index="province"
                    title="Province"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="postalcode"
                    index="postalcode"
                    title="Postal Code"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'4'}"
                    editrules="{number:true,required:true}"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="loanappdocumentno"
                    index="loanappdocumentno"
                    title="Loan Application Document"
                    sortable="true"
                    search="true"
                    searchoptions="{sopt:['eq']}"
                    align="center"
                    />
    
    <sjg:gridColumn name="floorarea"
                    index="floorarea"
                    title="Floor Area"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="lotarea"
                    index="lotarea"
                    title="Lot Area"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="stability"
                    index="stability"
                    title="Stability"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="model"
                    index="model"
                    title="Model"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="make"
                    index="make"
                    title="Make"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="land"
                    index="land"
                    title="Land"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="monthlyrental"
                    index="monthlyrental"
                    title="Monthly Rental"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    editrules="{number:true}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="landlordname"
                    index="landlordname"
                    title="Land Lord Name"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="landlordaddress"
                    index="landlordaddress"
                    title="Land Lord Address"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
    
    <sjg:gridColumn name="landlordphoneno"
                    index="landlordphoneno"
                    title="Land Lord Contact"
                    editable="true"
                    edittype="text"
                    editoptions="{maxlength:'45'}"
                    hidden="true"
                    sortable="true"
                    align="center"
                    />
</sjg:grid>
